package com.github.xjjdog.concurrent;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class GoodDateFormat {
    ThreadLocal<SimpleDateFormat> format = new ThreadLocal<SimpleDateFormat>(){
        @Override
        protected SimpleDateFormat initialValue() {
            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        }
    };
    public static void main(String[] args) {
       final GoodDateFormat faultDateFormat = new GoodDateFormat();
       ExecutorService executor = Executors.newCachedThreadPool();
       for(int i=0;i<1000;i++){
           executor.submit(()-> {
               try {
                   System.out.println(faultDateFormat.format.get().parse("2020-07-25 08:56:40"));
               } catch (ParseException e) {
                   throw new IllegalStateException();
               }
           });
       }
       executor.shutdown();
    }
}
